package algorithm;

import java.util.ArrayList;
import java.util.List;

/**
 * User: Asuka
 * Date: 11-3-23
 * Time: 下午7:35
 */
public class TwiceSuperCubic {

    public static void main(String[] args) {
        TwiceSuperCubic test = new TwiceSuperCubic();
        long start = System.nanoTime();
        long timeUsed = System.nanoTime() - start;
        test.superCubic(1729);
        System.out.println("timeUsed:" + timeUsed);
    }

    public void superCubic(int n) {
        List<Integer> elements = new ArrayList<Integer>();
        for (int i = 0; i <= Math.cbrt(n); i++) {
            elements.add((int) Math.pow(i, 3));
        }
        System.out.println(elements);
        for (int i = 0; i < elements.size() - 1; i++) {
            for (int j = i + 1; j < elements.size(); j++) {
                if (elements.get(i) + elements.get(j) == n) {
                    System.out.println((int) Math.cbrt(elements.get(i)) + "^3 + " + (int) Math.cbrt(elements.get(j)) + "^3 = " + n);
                }
            }
        }
    }

    public static void test() {

    }
}
